/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.eng.scc.core.details;

import com.eng.scc.core.data.Company;
import com.eng.scc.core.data.Driver;
import com.eng.scc.core.data.People;
import com.eng.scc.core.data.Vehicle;
import com.eng.scc.core.db.manager.service.FuelControllerManagerService;
import com.eng.scc.core.util.HTMLFactory;
import com.eng.scc.core.view.ApplicationContext;

/**
 *
 * @author Rafael
 */
public class VehicleDetails
{
    public static HTMLFactory.Body getDetails( Vehicle v )
    {
        HTMLFactory.Body body = new HTMLFactory.Body();
        
        try
        {
            Driver d = FuelControllerManagerService.getInstance().getDriver( v.getDriverId() );
            
            HTMLFactory.Title title = new HTMLFactory.Title( "Veículo: " + v.getModel() );
            
            body.addContent( title );
            
            HTMLFactory.TableDetails details = new HTMLFactory.TableDetails();
            
            Company company = FuelControllerManagerService.getInstance().getCompany( v.getCompanyId() );
            
            details.addItem( "Empresa", company.getFantasyName());

            if ( d != null )
            {
                People p = FuelControllerManagerService.getInstance().getPeople( d.getPeopleId() );
                details.addItem( "Motorista", p != null ? p.getName() : "n/d");
            }
            
            details.addItem( "Placa", v.getPlate() );
            details.addItem( "Marca", v.getBrand() );
            details.addItem( "Modelo", v.getModel() );
            details.addItem( "Ano/Modelo", v.getManufacturingYear() + "/" + v.getModelYear() );
            details.addItem( "Renavam", v.getRenavam() );
            details.addItem( "N° Chassi", v.getChassi() );
            details.addItem( "Tipo de Carroceria", v.getTruckModel().toString() );
            details.addItem( "Capacidade Máx. Carroceria", v.getCapacity() );
            details.addItem( "Qtde. Eixos", v.getAxles() );
            details.addItem( "Capacidade Máx. Combustível (L)", v.getMaxFuel() );
            details.addItem( "Média Fabricante (km/L)", v.getManufacturingAvg() );
            
              
            body.addContent( details );

        }
        catch ( Exception e )
        {
            ApplicationContext.getInstance().saveLog( e );
        }
        
        return body;
    }
}
